package com.itxckf.mapper;

import com.itxckf.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface LoginMapper {
    /**
     * 查询账户信息
     * @param user
     * @return
     */
    @Select("select * from users where Username = #{username} and Password = #{password};")
    User userLogin(User user);

    /**
     * 获取账号信息
     *
     */
    @Select("select * from users where userID = #{userID}")
    List<User> getUser(Integer id);

    /**
     * 注册账号
     * @param user
     */
    @Insert("INSERT INTO users (Username, Password,Phone,role,UserImage,TotalConsumption,Balance) VALUES (#{username}, #{password}, #{phone}, #{role}, #{userImage},#{totalConsumption},#{balance})")
    void register(User user);

    /**
     * 查询是否存在
     * @param userId
     * @return
     */
    @Select("select * from users where Username = #{username};")
    User isUser(String username);


}
